#define _CRT_SECURE_NO_WARNINGS 1


#include<vector>
#include<iostream>

using namespace std;

int _QuickSort(vector<int>& v, int left, int right)
{
    int keyi = left;
    left++;
    while (left <= right)
    {
        while (left <= right && v[right] < v[keyi])
        {
            right--;
        }
        while (left <= right && v[left] > v[keyi])
        {
            left++;
        }
        if (left <= right)
        {
            swap(v[left++], v[right--]);
        }
    }
    swap(v[keyi], v[right]);
    return right;
}

void QuickSort(vector<int>& v, int left, int right)
{
    if (left >= right)
    {
        return;
    }
    int keyi = _QuickSort(v, left, right);
    QuickSort(v, left, keyi - 1);
    QuickSort(v, keyi + 1, right);
}

int findKth(vector<int>& a, int n, int K)
{
    QuickSort(a, 0, n - 1);
    return a[K - 1];
}